package com.common.base;

import lombok.Data;

import java.io.Serializable;
import java.util.List;

/**
 * @类名 UserInfo
 * @描述 TODO 请求中用户信息
 * @版本 1.0
 * @创建人 lying
 * @创建时间 2020/4/14 15:39
 * @修改人 lying
 * @修改时间 2020/4/14 15:39
 **/
@Data
public class UserInfo<T> implements Serializable {
    private static final long serialVersionUID = 7623302262952519240L;

    private T object;
    private String userName;
    private Integer userId;
    private List<RoleInfoPO> roles;
    private String ip;
    private String deviceId;
    private String deviceModel;
    private String deviceSystem;
    private String version;

    public UserInfo(T object) {
        this.object = object;
    }

    public UserInfo() {

    }

    public T setPublicAttribute(T t){
        if ( t instanceof BaseVO) {
            ((BaseVO) t).setCreator(this.userName);
            ((BaseVO) t).setCreatorId(this.userId);
            ((BaseVO) t).setUpdator(this.userName);
        }

        return t;
    }

    public List<RoleInfoPO> getRoles() {
        return roles;
    }

    public void setRoles(List<RoleInfoPO> roles) {
        this.roles = roles;
    }

    public T getObject() {
        return object;
    }

    public void setObject(T object) {
        this.object = object;
    }

    public String getUserName() {
        return userName;
    }

    public void setUserName(String userName) {
        this.userName = userName;
    }

    public Integer getUserId() {
        return userId;
    }

    public void setUserId(Integer userId) {
        this.userId = userId;
    }


    public String getIp() {
        return ip;
    }

    public void setIp(String ip) {
        this.ip = ip;
    }

    public String getDeviceId() {
        return deviceId;
    }

    public void setDeviceId(String deviceId) {
        this.deviceId = deviceId;
    }

    public String getDeviceModel() {
        return deviceModel;
    }

    public void setDeviceModel(String deviceModel) {
        this.deviceModel = deviceModel;
    }

    public String getDeviceSystem() {
        return deviceSystem;
    }

    public void setDeviceSystem(String deviceSystem) {
        this.deviceSystem = deviceSystem;
    }

    public String getVersion() {
        return version;
    }

    public void setVersion(String version) {
        this.version = version;
    }

    public UserInfo(T object, String userName, Integer userId, List<RoleInfoPO> roles, String ip, String deviceId, String deviceModel, String deviceSystem, String version) {
        this.object = object;
        this.userName = userName;
        this.userId = userId;
        this.roles = roles;
        this.ip = ip;
        this.deviceId = deviceId;
        this.deviceModel = deviceModel;
        this.deviceSystem = deviceSystem;
        this.version = version;
    }
}
